<template>
  <div class="m-news-index">
    <!-- 头部背景图 -->
    <img class="news-bg" :src="locale == 'en-US' ? enNewsBg : zhNewsBg" :alt="`${$t('platform')}`" />
    <div class="m-container">
      <!-- 分类名称 -->
      <div class="category-name">
        <span>{{ $t("industryNews") }}</span>
        <a class="more-article" :href="`/m-news-list/1`" :title="`${$t('industryNews')}`">
          <span>{{ $t("viewMore") }}</span>
          <i class="arrow el-icon-arrow-right"></i>
        </a>
      </div>
      <!-- 图文列表 -->
      <section class="article-list">
        <a class="article-item" v-for="item in industryList" :key="item.id" :href="`/m-news-detail/${item.id}`" :title="item.title">
          <el-image class="info-img" fit="cover" :src="item.imageUrl" lazy :alt="item.title"></el-image>
          <div class="info-bottom">
            <div class="info-title">{{ item.title }}</div>
            <div class="release-time">{{ item.releaseTime }}</div>
          </div>
        </a>
      </section>
      <!-- 分类名称 -->
      <div class="category-name">
        <span>{{ $t("transactionCase") }}</span>
        <a class="more-article" :href="`/m-news-list/2`" :title="`${$t('transactionCase')}`">
          <span>{{ $t("viewMore") }}</span>
          <i class="arrow el-icon-arrow-right"></i>
        </a>
      </div>
      <!-- 图文列表 -->
      <section class="article-list">
        <a class="article-item" v-for="item in transactionCaseList" :key="item.id" :href="`/m-news-detail/${item.id}`" :title="item.title">
          <el-image class="info-img" fit="cover" :src="item.imageUrl" lazy :alt="item.title"></el-image>
          <div class="info-bottom">
            <div class="info-title">{{ item.title }}</div>
            <div class="release-time">{{ item.releaseTime }}</div>
          </div>
        </a>
      </section>
    </div>
    <!-- WhatsApp -->
    <!-- <WhatsAppM v-if="locale == 'en-US'" /> -->
    <!-- 底部信息 -->
    <FooterM></FooterM>
  </div>
</template>

<script>
import { mapState } from "vuex"
export default {
  name: "M-newsIndex",
  layout: "mobile",
  data() {
    return {
      zhNewsBg: "https://yunlian-oss-product.oss-cn-hangzhou.aliyuncs.com/website/m-news-bg.png",
      enNewsBg: "https://yunlian-oss-product.oss-cn-hangzhou.aliyuncs.com/website/m-news-bg-en.png"
    }
  },
  head() {
    return {
      title: this.$i18n.t("headTitle"),
      meta: [
        {
          hid: "keywords",
          name: "keywords",
          content: this.$i18n.t("haeaKeyContent")
        },
        {
          hid: "description",
          name: "description",
          content: this.$i18n.t("haeaDecContent")
        }
      ]
    }
  },
  async asyncData({ app, query }) {
    let industryForm = {
        pageNo: 1,
        pageSize: 4,
        sort: "id desc"
      },
      transactionCaseForm = {
        pageNo: 1,
        pageSize: 8,
        sort: "id desc"
      },
      industryList = [],
      transactionCaseList = []
    try {
      let { data: industryData } = await app.$api.articleList({ ...industryForm, search: { categoryName: "1" } })
      industryList = industryData.list
      let { data: transactionCaseData } = await app.$api.articleList({ ...transactionCaseForm, search: { categoryName: "2" } })
      transactionCaseList = transactionCaseData.list
    } catch (error) {
      console.log(error)
    }
    return {
      industryList,
      transactionCaseList
    }
  },
  props: {},
  computed: { ...mapState(["locale"]) },
  async mounted() {
    this.getPoint()
  },
  methods: {
    async getPoint() {
      let params = await this.$optionPoint.sendUrl(window, navigator, document)
      this.$api.burySave({ ...params }).then((res) => {})
    }
  }
}
</script>

<style lang="scss" scoped>
.m-news-index {
  .news-bg {
    width: 100%;
    height: 1024px;
  }
  .category-name {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 80px;
    span {
      font-size: 82px;
      font-weight: 500;
      color: #333;
      line-height: 82px;
    }
    .more-article {
      display: flex;
      align-items: center;
      span {
        font-family: PingFangSC, PingFang SC;
        font-weight: 400;
        font-size: 60px;
        color: #333;
      }
      .arrow {
        font-size: 80px;
        color: #333;
      }
    }
  }
  .article-list {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-top: 80px;
    .article-item {
      width: 860px;
      height: 100%;
      margin-bottom: 50px;
      .info-img {
        width: 860px;
        height: 543px;
        display: block;
      }
      .info-bottom {
        width: 100%;
        height: 486px;
        background: #f6f7f9;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        padding: 50px;
        box-sizing: border-box;
        .info-title {
          font-family: PingFangSC, PingFang SC;
          font-weight: 500;
          font-size: 72px;
          color: #333;
          line-height: 92px;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 2;
          text-overflow: ellipsis;
          overflow: hidden;
        }
        .release-time {
          font-family: PingFangSC, PingFang SC;
          font-weight: 400;
          font-size: 60px;
          color: #999;
          line-height: 80px;
        }
      }
    }
  }
}
</style>
